<template>
  <div class="page-body">
    <AppHeader />
    <div class="market-hero">
      <div class="market-hero-content">
        <h1 class="market-hero-title">需求大厅</h1>
        <p class="market-hero-desc">发现、发布、解决一切需求，助力每个人的美好生活</p>
      </div>
    </div>
    <main class="market-main">
      <div class="market-page">
        <div class="market-search-bar">
          <el-input v-model="search" placeholder="搜索需求/关键词" class="search-input" clearable />
          <el-button type="primary" class="search-btn gradient-btn">搜索需求</el-button>
        </div>
        <div class="market-tags-area">
          <div class="market-tags">
            <div class="tag-group">
              <span class="tag-label">分类筛选：</span>
              <el-tag
                v-for="cat in categories"
                :key="cat"
                :type="cat === activeCategory ? 'primary' : 'info'"
                class="tag-item"
                @click="activeCategory = cat"
                :effect="cat === activeCategory ? 'dark' : 'plain'"
                >{{ cat }}</el-tag
              >
            </div>
            <div class="tag-group">
              <span class="tag-label">智能排序：</span>
              <el-tag
                v-for="rec in recommends"
                :key="rec"
                :type="rec === activeRecommend ? 'primary' : 'info'"
                class="tag-item"
                @click="activeRecommend = rec"
                :effect="rec === activeRecommend ? 'dark' : 'plain'"
                >{{ rec }}</el-tag
              >
            </div>
            <div class="market-count">
              共找到 <b>{{ demandList.length }}</b> 个需求
            </div>
          </div>
        </div>
        <el-divider />
        <div class="demand-list">
          <el-empty v-if="demandList.length === 0" description="暂无相关需求" />
          <div v-for="item in demandList" :key="item.id" class="demand-card">
            <div class="demand-img-wrap">
              <img :src="item.img" :alt="item.title" class="demand-img" />
              <span v-if="item.top" class="demand-top">置顶</span>
            </div>
            <div class="demand-info">
              <div class="demand-title">{{ item.title }}</div>
              <div class="demand-desc">{{ item.desc }}</div>
              <div class="demand-meta">
                <span class="demand-price">￥{{ item.price }}</span>
                <span class="demand-time">{{ item.time }}</span>
              </div>
              <div class="demand-user-row">
                <span class="demand-user">{{ item.user }}</span>
                <span class="demand-stats">浏览 {{ item.views }} | 报价 {{ item.quotes }}</span>
              </div>
            </div>
          </div>
        </div>
        <div class="market-more">
          <el-button type="primary" size="large" class="gradient-btn">加载更多需求</el-button>
        </div>
      </div>
    </main>
  </div>
</template>
<script setup>
import { ref } from "vue";
import AppHeader from "@/components/AppHeader.vue";
const search = ref("");
const categories = ["全部需求", "开发技术", "设计创作", "营销推广", "电商运营", "生活服务"];
const recommends = ["最新发布", "按价格多", "即将截止"];
const activeCategory = ref("全部需求");
const activeRecommend = ref("最新发布");
const demandList = [
  {
    id: 1,
    title: "高薪前端开发工程师（React）",
    desc: "需要一位能胜任高强度远程工作的前端开发工程师，要求精通 React 技术栈，有实际项目经验。",
    price: 25000,
    time: "2 小时前",
    user: "王思源",
    views: 235,
    quotes: 18,
    img: "/src/assets/test.png",
    top: true,
  },
  {
    id: 2,
    title: "品牌 VI 设计",
    desc: "新创企业急需品牌视觉形象及相关物料设计，包括logo、名片、办公用品等整体设计，风格清新简洁。",
    price: 18000,
    time: "4 小时前",
    user: "李慧琪",
    views: 186,
    quotes: 12,
    img: "/src/assets/test.png",
    top: false,
  },
  {
    id: 3,
    title: "电商运营专员",
    desc: "招聘有经验的天猫运营专员，负责店铺运营、活动策划和数据分析，要求有相关行业经验。",
    price: 12000,
    time: "6 小时前",
    user: "姜红武",
    views: 324,
    quotes: 24,
    img: "/src/assets/test.png",
    top: true,
  },
  {
    id: 4,
    title: "iOS 移动应用开发",
    desc: "需要开发一款社交型原生 iOS 应用，要求有类似社交 APP 开发经验，具备良好的产品思维。",
    price: 30000,
    time: "8 小时前",
    user: "郝启源",
    views: 156,
    quotes: 9,
    img: "/src/assets/test.png",
    top: false,
  },
  {
    id: 5,
    title: "短视频内容策划",
    desc: "招聘短视频内容策划，负责公司短视频号整体内容规划和脚本撰写，要求有相关策划经验。",
    price: 8000,
    time: "12 小时前",
    user: "魏晓霞",
    views: 428,
    quotes: 31,
    img: "/src/assets/test.png",
    top: true,
  },
  {
    id: 6,
    title: "Python 数据分析项目",
    desc: "需要一名有经验的 Python 开发工程师协助开发数据分析模块，要求熟悉数据可视化和数据挖掘。",
    price: 15000,
    time: "3 小时前",
    user: "邢明",
    views: 265,
    quotes: 15,
    img: "/src/assets/test.png",
    top: false,
  },
];
</script>
<style scoped>
.page-body {
  width: 100%;
  background: #f7f9fb;
  min-height: 100vh;
}
.market-hero {
  width: 100%;
  background: linear-gradient(90deg, #e0e7ff 0%, #f0f7ff 100%);
  padding: 48px 0 24px 0;
  margin-bottom: 0;
}
.market-hero-content {
  max-width: 1200px;
  margin: 0 auto;
  text-align: left;
  padding-left: 32px;
}
.market-hero-title {
  font-size: 36px;
  font-weight: bold;
  color: #222;
  margin-bottom: 10px;
}
.market-hero-desc {
  font-size: 18px;
  color: #666;
  margin-bottom: 0;
}
.market-main {
  width: 100%;
  display: flex;
  justify-content: center;
}
.market-page {
  box-sizing: border-box;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto 48px auto;
  padding: 0 24px 32px 24px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px #e3e8f0;
  min-height: 600px;
}
.market-search-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 18px;
  padding: 24px 0 0 0;
}
.search-input {
  width: 340px;
  margin-right: 12px;
  border-radius: 24px;
  box-shadow: 0 2px 8px #e0e7ff;
  background: #f7f9fb;
}
.search-btn.gradient-btn {
  background: linear-gradient(90deg, #6a8dff 0%, #4fd1c5 100%);
  color: #fff;
  border: none;
  border-radius: 24px;
  font-weight: bold;
  box-shadow: 0 2px 8px #e0e7ff;
}
.market-tags-area {
  background: #f7f9fb;
  border-radius: 8px;
  margin-bottom: 0;
  padding: 10px;
}
.market-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.tag-group {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.tag-label {
  color: #888;
  font-size: 15px;
  margin-right: 4px;
}
.tag-item {
  cursor: pointer;
  font-size: 15px;
  border-radius: 16px;
  padding: 10px 16px;
  margin-right: 2px;
  height: auto;
  transition: background 0.2s, color 0.2s;
}
.market-count {
  margin-left: auto;
  color: #888;
  font-size: 15px;
}
.demand-list {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 32px 24px;
  margin-bottom: 32px;
  min-height: 320px;
  justify-items: center;
}
.demand-card {
  width: 30%;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 8px #e3e8f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
  position: relative;
  border: 1.5px solid #f0f0f0;
}
.demand-card:hover {
  box-shadow: 0 8px 24px #dbeafe;
  transform: translateY(-6px) scale(1.02);
  border-color: #a5b4fc;
}
.demand-img-wrap {
  position: relative;
}
.demand-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #f0f0f0;
}
.demand-top {
  position: absolute;
  top: 12px;
  right: 12px;
  background: linear-gradient(90deg, #f56c6c 0%, #fbbf24 100%);
  color: #fff;
  font-size: 13px;
  border-radius: 12px;
  padding: 2px 12px;
  font-weight: bold;
  box-shadow: 0 2px 8px #f0f1f3;
}
.demand-info {
  padding: 18px 18px 10px 18px;
}
.demand-title {
  font-size: 17px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #222;
}
.demand-desc {
  color: #666;
  font-size: 15px;
  height: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 12px;
  min-height: 38px;
}
.demand-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #888;
  font-size: 14px;
  margin-bottom: 8px;
}
.demand-price {
  color: #1976d2;
  font-weight: bold;
  font-size: 16px;
}
.demand-time {
  color: #aaa;
  font-size: 14px;
  text-align: right;
}
.demand-user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #888;
  font-size: 14px;
  margin-top: 2px;
}
.demand-user {
  color: #888;
}
.demand-stats {
  color: #bbb;
  font-size: 13px;
}
.market-more {
  text-align: center;
  margin: 32px 0 0 0;
}
.gradient-btn {
  background: linear-gradient(90deg, #6a8dff 0%, #4fd1c5 100%) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 24px !important;
  font-weight: bold;
  box-shadow: 0 2px 8px #e0e7ff;
}
</style>
